package chamster.statemachine;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import chamster.BaseHamster;

public class NEAMachine<HamsterType extends BaseHamster> implements StateMachine<HamsterType> {

	public HamsterState<HamsterType> run(HamsterType hamster,
			HamsterState<HamsterType> state) throws Exception {
		List<HamsterState<HamsterType>> newStates = 
				state.applyState(new ArrayList<HamsterState<HamsterType>>(), hamster);
		int selectedIndex = new Random().nextInt(newStates.size());
		return newStates.get(selectedIndex);
	}

}
